package com.huai.demo_test1.singletionsecond.staticInner;import java.io.Serializable;/** * 静态加载，延迟加载 * 静态内部类只有在被使用到的时候才会被jvm加载，所以算是延迟加载 * @author huaixiaohuan */public class StaticInnerClassSingletonOk implements Serializable {    private static class InnerClass {        private static StaticInnerClassSingletonOk staticInnerClassSingleton = new StaticInnerClassSingletonOk();    }    public static StaticInnerClassSingletonOk getInstance(){        return InnerClass.staticInnerClassSingleton;    }    /**     * 可以防止反射，并通过测试     */    private StaticInnerClassSingletonOk() {//        if (InnerClass.staticInnerClassSingleton!=null){//            throw new RuntimeException("单例构造器禁止反射调用");//        }    }}